<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* #father{
            width: 600px;
            height: 600px;
            background-color: red;
        } */
    </style>
</head>
<body>
    <!-- <div id="father">
        <button id="btn">点我</button>
    </div> -->
    <ul id="ul">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
    <script>
        // let father = document.getElementById('father');
        // let btn = document.getElementById('btn');

        // btn.addEventListener('click',function(){
        //     alert('点击了该按钮')
        // })
        // father.addEventListener('click',function(){
        //     alert('点击红色盒子')
        // })
        // document.addEventListener('click',function(){
        //     alert('点击了文档')
        // })
    </script>
    <script id="阻止事件冒泡">
        // let father = document.getElementById('father');
        // let btn = document.getElementById('btn');

        // btn.addEventListener('click',function(event){
        //     //阻止事件冒泡
        //     event.stopPropagation();//使用该函数之后，只会响应该事件
        //     alert('点击了该按钮')
        // })
        // father.addEventListener('click',function(){
        //     alert('点击红色盒子')
        // })
        // document.addEventListener('click',function(){
        //     alert('点击了文档')
        // })
        let ul = document.getElementById('ul')
        ul.addEventListener('click',function(event){
            console.log(event.target)//自动判断我们点的是哪个元素
            console.log(event.currentTarget)//整个目标事件源
        })
    </script>
</body>
</html>